home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / pcomm / part03 < prev    next >
Encoding:
Internet Message Format  |  1988-05-17  |  48.9 KB

  1. Subject:  v14i101:  Dial out and terminal emulator, Part03/06
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: fthood!egray@uunet.UU.NET
  7. Posting-number: Volume 14, Issue 101
  8. Archive-name: pcomm/part03
  9.  
  10. #! /bin/sh
  11. # This is a shell archive, meaning:
  12. # 1. Remove everything above the #! /bin/sh line.
  13. # 2. Save the resulting text in a file.
  14. # 3. Execute the file with /bin/sh (not csh) to create:
  15. #    d_print.c
  16. #    d_prompt.c
  17. #    d_revise.c
  18. #    data_log.c
  19. #    di_delay.c
  20. #    di_win.c
  21. #    dial.c
  22. #    expand.c
  23. #    getcwd.c
  24. #    getopt.c
  25. #    help.c
  26. #    info.c
  27. #    init.c
  28. export PATH; PATH=/bin:/usr/bin:$PATH
  29. echo shar: "extracting 'd_print.c'" '(3497 characters)'
  30. if test -f 'd_print.c'
  31. then
  32.     echo shar: "will not over-write existing file 'd_print.c'"
  33. else
  34. sed 's/^X//' << \SHAR_EOF > 'd_print.c'
  35. X/*
  36. X * The print option of the dialing directory.  A carriage return will
  37. X * send the dialing directory to the print spool program, otherwise the
  38. X * selected file will be used.
  39. X */
  40. X
  41. X#define LPRINT "/usr/bin/lprint"
  42. X
  43. X#include <stdio.h>
  44. X#include <curses.h>
  45. X#include "dial_dir.h"
  46. X#include "misc.h"
  47. X
  48. Xvoid
  49. Xprint_dir()
  50. X{
  51. X    FILE *fp, *popen();
  52. X    WINDOW *p_win, *newwin();
  53. X    char *file, *get_str_erase(), buf[80];
  54. X    int is_printer, i, can;
  55. X    void error_win();
  56. X    unsigned int sleep();
  57. X    
  58. X    p_win = newwin(5, 54, 0, 26);
  59. X
  60. X    mvwaddstr(p_win, 2, 3, "Print to: (printer)");
  61. X    box(p_win, '|', '-');
  62. X    wmove(p_win, 2, 13);
  63. X    wrefresh(p_win);
  64. X
  65. X    /*
  66. X     * This is a special version of get_str() that looks at the
  67. X     * first character to see if it should erase the default answer
  68. X     * already on the screen.
  69. X     */
  70. X    if ((file = get_str_erase(p_win, 40)) == NULL) {
  71. X                    /* erase because it overlaps dm_win */
  72. X        werase(p_win);
  73. X        wrefresh(p_win);
  74. X        delwin(p_win);
  75. X        return;
  76. X    }
  77. X    is_printer = 0;
  78. X                    /* the default (printer) */
  79. X    if (*file == NULL) {
  80. X        if (!(fp = popen(LPRINT, "w"))) {
  81. X            sprintf(buf, "'%s'", LPRINT);
  82. X            error_win(0, "Can't open printer device", buf);
  83. X            werase(p_win);
  84. X            wrefresh(p_win);
  85. X            delwin(p_win);
  86. X            return;
  87. X        }
  88. X        is_printer = 1;
  89. X    }
  90. X                    /* the requested file */
  91. X    else {
  92. X        /*
  93. X         * Check to see if the file already exists (and if we
  94. X         * have write permission too).  Currently only allows
  95. X         * you to bail out or overwrite the file.
  96. X         */
  97. X        if (!(can = can_write(file))) {
  98. X            sprintf(buf, "'%s'", file);
  99. X            error_win(0, "No write permission on file", buf);
  100. X            werase(p_win);
  101. X            wrefresh(p_win);
  102. X            delwin(p_win);
  103. X            return;
  104. X        }
  105. X        if (can == 2) {
  106. X            werase(p_win);
  107. X            mvwprintw(p_win, 2, 3, "File '%s' already exists!", file);
  108. X            beep();
  109. X            box(p_win, '|', '-');
  110. X            if (!yes_prompt(p_win, 3, 3, A_BOLD, "Overwrite")) {
  111. X                werase(p_win);
  112. X                wrefresh(p_win);
  113. X                delwin(p_win);
  114. X                return;
  115. X            }
  116. X        }
  117. X            
  118. X        fp = fopen(file, "w");
  119. X    }
  120. X    
  121. X    werase(p_win);
  122. X    mvwaddstr(p_win, 2, 13, "Printing pcomm directory");
  123. X    box(p_win, '|', '-');
  124. X    wrefresh(p_win);
  125. X
  126. X    /*
  127. X     * Only prints up to the end of the physical file, not the entire
  128. X     * structure.  I gave some thought about not printing empty entries,
  129. X     * but...
  130. X     */
  131. X    for (i=1; i<=dir->d_entries; i++)
  132. X        fprintf(fp, "%4d- %-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  133. X         i, dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  134. X         dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->index[i]);
  135. X
  136. X    if (is_printer)
  137. X        pclose(fp);
  138. X    else {
  139. X                    /* a dramatic delay... */
  140. X        sleep(1);
  141. X        fclose(fp);
  142. X    }
  143. X
  144. X    werase(p_win);
  145. X    wrefresh(p_win);
  146. X    delwin(p_win);
  147. X    return;
  148. X}
  149. X
  150. X/*
  151. X * Get a string from a window but erase the line first.
  152. X */
  153. X
  154. Xchar *
  155. Xget_str_erase(win, num)
  156. XWINDOW *win;
  157. Xint num;
  158. X{
  159. X    int count, x, y, done_it;
  160. X    char ans;
  161. X    static char buf[80];
  162. X
  163. X    done_it = 0;
  164. X    count = 0;
  165. X    while ((ans = wgetch(win)) != '\r') {
  166. X                    /* do our own backspace */
  167. X        if (ans == 8) {
  168. X            if (!count) {
  169. X                beep();
  170. X                continue;
  171. X            }
  172. X            count--;
  173. X            buf[count] = NULL;
  174. X            getyx(win, y, x);
  175. X            x--;
  176. X            wmove(win, y, x);
  177. X            waddch(win, ' ');
  178. X            wmove(win, y, x);
  179. X            wrefresh(win);
  180. X            continue;
  181. X        }
  182. X                    /* exceeded the max ? */
  183. X        if (count == num) {
  184. X            beep();
  185. X            continue;
  186. X        }
  187. X                    /* an ESC anywhere in the string */
  188. X        if (ans == 27)
  189. X            return(NULL);
  190. X                    /* erase the default answer */
  191. X        if (!done_it) {
  192. X            waddstr(win, "         ");
  193. X            wmove(win, 2, 13);
  194. X            wrefresh(win);
  195. X            done_it = 1;
  196. X        }
  197. X
  198. X        buf[count] = ans;
  199. X        waddch(win, ans);
  200. X        wrefresh(win);
  201. X        count++;
  202. X    }
  203. X    buf[count] = NULL;
  204. X    return(buf);
  205. X}
  206. SHAR_EOF
  207. if test 3497 -ne "`wc -c < 'd_print.c'`"
  208. then
  209.     echo shar: "error transmitting 'd_print.c'" '(should have been 3497 characters)'
  210. fi
  211. fi
  212. echo shar: "extracting 'd_prompt.c'" '(5941 characters)'
  213. if test -f 'd_prompt.c'
  214. then
  215.     echo shar: "will not over-write existing file 'd_prompt.c'"
  216. else
  217. sed 's/^X//' << \SHAR_EOF > 'd_prompt.c'
  218. X/*
  219. X * Prompt for directory entry changes.  Copies the original values in
  220. X * case you change your mind half way thru.  A return code of 1 means
  221. X * the entry was changed.
  222. X */
  223. X
  224. X#include <stdio.h>
  225. X#include <curses.h>
  226. X#include "dial_dir.h"
  227. X#include "misc.h"
  228. X
  229. Xint
  230. Xprompt_lib(win, i)
  231. XWINDOW *win;
  232. Xint i;
  233. X{
  234. X    int n, baud, dbits, sbits, spot;
  235. X    static int valid_baud[6] = {300, 1200, 2400, 4800, 9600, 19200};
  236. X    static char *valid_parity[3] = {"Even", "Odd", "None"};
  237. X    char *ans, *get_str(), c, temp, *name, *number, *index, parity;
  238. X    char duplex, *strdup(), buf[40];
  239. X    void free_ptr();
  240. X    extern int xmc;
  241. X    extern char *null_ptr;
  242. X                    /* make copies */
  243. X    name = strdup(dir->name[i]);
  244. X    number = strdup(dir->number[i]);
  245. X    baud = dir->baud[i];
  246. X    parity = dir->parity[i];
  247. X    dbits = dir->dbits[i];
  248. X    sbits = dir->sbits[i];
  249. X    duplex = dir->duplex[i];
  250. X    index = strdup(dir->index[i]);
  251. X                    /* display original values */
  252. X    werase(win);
  253. X    mvwprintw(win, 2, 5, "%-20.20s %18.18s  %5d-%c-%d-%d  %c  %-14.14s\n",
  254. X     dir->name[i], dir->number[i], dir->baud[i], dir->parity[i],
  255. X     dir->dbits[i], dir->sbits[i], dir->duplex[i], dir->index[i]);
  256. X    box(win, '|', '-');
  257. X
  258. X                    /* prompt for name */
  259. X    mvwaddstr(win, 4, 4, "Name: ");
  260. X    wrefresh(win);
  261. X
  262. X    if ((ans = get_str(win, 20, NULL, ";")) == NULL)
  263. X        return(0);
  264. X    if (*ans != NULL) {
  265. X        if (!strcmp(ans, " "))
  266. X            name = null_ptr;
  267. X        else
  268. X            name = strdup(ans);
  269. X        mvwaddstr(win, 2, 5, "                    ");
  270. X        wrefresh(win);
  271. X        mvwattrstr(win, 2, 5, A_BOLD, name);
  272. X    }
  273. X                    /* prompt for number */
  274. X    clear_line(win, 4, 4, 1);
  275. X    waddstr(win, "Number: ");
  276. X    wrefresh(win);
  277. X
  278. X    if ((ans = get_str(win, 18, NULL, ";")) == NULL)
  279. X        return(0);
  280. X    if (*ans != NULL) {
  281. X        if (!strcmp(ans, " "))
  282. X            number = null_ptr;
  283. X        else
  284. X            number = strdup(ans);
  285. X        mvwaddstr(win, 2, 26, "                  ");
  286. X        wrefresh(win);
  287. X        /*
  288. X         * Should be right justified, but we don't wanna to have
  289. X         * the attribute turned on for blanks.
  290. X         */
  291. X        spot = 26 + 18 - strlen(number);
  292. X        mvwattrstr(win, 2, spot, A_BOLD, number);
  293. X    }
  294. X                    /* template for next few */
  295. X    clear_line(win, 4, 4, 1);
  296. X    mvwaddstr(win, 4, 31, "(Any key to change, <CR> to accept)");
  297. X
  298. X    /*
  299. X     * These next few prompts display a series of choices and allow
  300. X     * the user to hit a return to accept the currently showing
  301. X     * value.  The first value displayed is always the current value.
  302. X     */
  303. X                    /* choose from baud menu */
  304. X    for (n=0; n<6; n++) {
  305. X        if (valid_baud[n] == baud)
  306. X            break;
  307. X    }
  308. X    mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  309. X    wmove(win, 4, 10);
  310. X    wrefresh(win);
  311. X
  312. X    while ((c = wgetch(win)) != '\r') {
  313. X        if (c == 27)
  314. X            return(0);
  315. X        n = (n == 5) ? 0 : n+1;
  316. X        mvwprintw(win, 4, 4, "Baud: %-5d", valid_baud[n]);
  317. X        wmove(win, 4, 10);
  318. X        wrefresh(win);
  319. X    }
  320. X    if (baud != valid_baud[n]) {
  321. X        baud = valid_baud[n];
  322. X        sprintf(buf, "%5d", baud);
  323. X        if (xmc > 0) {
  324. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  325. X            mvwaddstr(win, 2, 46, "           ");
  326. X            wrefresh(win);
  327. X        }
  328. X        mvwattrstr(win, 2, 46, A_BOLD, buf);
  329. X    }
  330. X                    /* choose from parity menu */
  331. X    for (n=0; n<3; n++) {
  332. X        if (*valid_parity[n] == parity)
  333. X            break;
  334. X    }
  335. X    mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  336. X    wmove(win, 4, 12);
  337. X    wrefresh(win);
  338. X
  339. X    while ((c = wgetch(win)) != '\r') {
  340. X        if (c == 27)
  341. X            return(0);
  342. X        n = (n == 2) ? 0 : n+1;
  343. X        mvwprintw(win, 4, 4, "Parity: %-5.5s", valid_parity[n]);
  344. X        wmove(win, 4, 12);
  345. X        wrefresh(win);
  346. X    }
  347. X    if (parity != *valid_parity[n]) {
  348. X        parity = *valid_parity[n];
  349. X        if (xmc > 0) {
  350. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  351. X            mvwaddstr(win, 2, 46, "           ");
  352. X            wrefresh(win);
  353. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  354. X        }
  355. X        else
  356. X            mvwattrch(win, 2, 52, A_BOLD, parity);
  357. X    }
  358. X                    /* choose from data bits menu */
  359. X    n = dbits;
  360. X    mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  361. X    wmove(win, 4, 15);
  362. X    wrefresh(win);
  363. X
  364. X    while ((c = wgetch(win)) != '\r') {
  365. X        if (c == 27)
  366. X            return(0);
  367. X        n = (n == 8) ? 7 : 8;
  368. X        mvwprintw(win, 4, 4, "Data Bits: %d    ", n);
  369. X        wmove(win, 4, 15);
  370. X        wrefresh(win);
  371. X    }
  372. X    if (dbits != n) {
  373. X        dbits = n;
  374. X        if (xmc > 0) {
  375. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  376. X            mvwaddstr(win, 2, 46, "           ");
  377. X            wrefresh(win);
  378. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  379. X        }
  380. X        else
  381. X            mvwattrnum(win, 2, 54, A_BOLD, dbits);
  382. X    }
  383. X                    /* choose from stop bits menu */
  384. X    n = sbits;
  385. X    mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  386. X    wmove(win, 4, 15);
  387. X    wrefresh(win);
  388. X
  389. X    while ((c = wgetch(win)) != '\r') {
  390. X        if (c == 27)
  391. X            return(0);
  392. X        n = (n == 2) ? 1 : 2;
  393. X        mvwprintw(win, 4, 4, "Stop Bits: %d    ", n);
  394. X        wmove(win, 4, 15);
  395. X        wrefresh(win);
  396. X    }
  397. X    if (sbits != n) {
  398. X        sbits = n;
  399. X        if (xmc > 0) {
  400. X            sprintf(buf, "%5d-%c-%d-%d", baud, parity, dbits, sbits);
  401. X            mvwaddstr(win, 2, 46, "           ");
  402. X            wrefresh(win);
  403. X            mvwattrstr(win, 2, 46, A_BOLD, buf);
  404. X        }
  405. X        else
  406. X            mvwattrnum(win, 2, 56, A_BOLD, sbits);
  407. X    }
  408. X                    /* choose from duplex menu */
  409. X    temp = duplex;
  410. X    mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  411. X    wmove(win, 4, 12);
  412. X    wrefresh(win);
  413. X
  414. X    while ((c = wgetch(win)) != '\r') {
  415. X        if (c == 27)
  416. X            return(0);
  417. X        temp = (temp == 'F') ? 'H' : 'F';
  418. X        mvwprintw(win, 4, 4, "Duplex: %c    ", temp);
  419. X        wmove(win, 4, 12);
  420. X        wrefresh(win);
  421. X    }
  422. X    if (duplex != temp) {
  423. X        duplex = temp;
  424. X        mvwattrch(win, 2, 59, A_BOLD, duplex);
  425. X    }
  426. X                    /* prompt for command line index */
  427. X    clear_line(win, 4, 4, 1);
  428. X    waddstr(win, "Command line index (or tty): ");
  429. X    wrefresh(win);
  430. X
  431. X    if ((ans = get_str(win, 14, NULL, ";")) == NULL)
  432. X        return(0);
  433. X    if (*ans != NULL) {
  434. X        if (!strcmp(ans, " "))
  435. X            index = null_ptr;
  436. X        else
  437. X            index = strdup(ans);
  438. X        mvwattrstr(win, 2, 62, A_BOLD, index);
  439. X    }
  440. X                    /* store 'em for real */
  441. X    free_ptr(dir->name[i]);
  442. X    free_ptr(dir->number[i]);
  443. X    free_ptr(dir->index[i]);
  444. X
  445. X    dir->name[i] = strdup(name);
  446. X    dir->number[i] = strdup(number);
  447. X    dir->baud[i] = baud;
  448. X    dir->parity[i] = parity;
  449. X    dir->dbits[i] = dbits;
  450. X    dir->sbits[i] = sbits;
  451. X    dir->duplex[i] = duplex;
  452. X    dir->index[i] = strdup(index);
  453. X
  454. X    free_ptr(name);
  455. X    free_ptr(number);
  456. X    free_ptr(index);
  457. X    return(1);
  458. X}
  459. SHAR_EOF
  460. if test 5941 -ne "`wc -c < 'd_prompt.c'`"
  461. then
  462.     echo shar: "error transmitting 'd_prompt.c'" '(should have been 5941 characters)'
  463. fi
  464. fi
  465. echo shar: "extracting 'd_revise.c'" '(3971 characters)'
  466. if test -f 'd_revise.c'
  467. then
  468.     echo shar: "will not over-write existing file 'd_revise.c'"
  469. else
  470. sed 's/^X//' << \SHAR_EOF > 'd_revise.c'
  471. X/*
  472. X * The revise option of the dialing directory.  A return code of 1 means
  473. X * that something was updated.  Prompts for saving changes to disk.
  474. X */
  475. X
  476. X#include <stdio.h>
  477. X#include <curses.h>
  478. X#include "dial_dir.h"
  479. X#include "misc.h"
  480. X#include "param.h"
  481. X
  482. Xint
  483. Xrevise()
  484. X{
  485. X    WINDOW *r_win, *newwin();
  486. X    int count, dir_flag, param_flag, num, x, y, save;
  487. X    char ans, buf[40], *ld, *prompt_ld(), *strdup();
  488. X    void free_ptr();
  489. X    
  490. X    r_win = newwin(7, 77, 7, 2);
  491. X
  492. X    mvwaddstr(r_win, 3, 6, "Entry to revise?");
  493. X    mvwaddstr(r_win, 3, 35, "(Entry Number, +, -, @, #)");
  494. X    box(r_win, '|', '-');
  495. X    wmove(r_win, 3, 23);
  496. X    wrefresh(r_win);
  497. X
  498. X    dir_flag = 0;
  499. X    param_flag = 0;
  500. X    count = 0;
  501. X
  502. X    /*
  503. X     * Can't use my home-grown get_str() and get_num() functions
  504. X     * here, because we are prompting for an entry number or a
  505. X     * long distance code.  This routine echoes numbers only.
  506. X     */
  507. X    while ((ans = wgetch(r_win)) != 27) {
  508. X        if (ans >= '0' && ans <= '9') {
  509. X            if (count == 3) {
  510. X                beep();
  511. X                continue;
  512. X            }
  513. X            buf[count] = ans;
  514. X            waddch(r_win, ans);
  515. X            wrefresh(r_win);
  516. X            count++;
  517. X            continue;
  518. X        }
  519. X                    /* terminating <CR> */
  520. X        if (ans == '\r') {
  521. X            if (!count) {
  522. X                beep();
  523. X                continue;
  524. X            }
  525. X            buf[count] = NULL;
  526. X            num = atoi(buf);
  527. X                    /* valid range of numbers? */
  528. X            if (num == 0 || num > NUM_DIR) {
  529. X                beep();
  530. X                mvwaddstr(r_win, 3, 23, "   ");
  531. X                wmove(r_win, 3, 23);
  532. X                wrefresh(r_win);
  533. X                count = 0;
  534. X                continue;
  535. X            }
  536. X                    /* prompt for that entry */
  537. X            if (prompt_lib(r_win, num)) {
  538. X                dir_flag++;
  539. X                break;
  540. X            }
  541. X            delwin(r_win);
  542. X            return(0);
  543. X        }
  544. X                    /* do our own backspace */
  545. X        if (ans == 8) {
  546. X            if (!count) {
  547. X                beep();
  548. X                continue;
  549. X            }
  550. X            count--;
  551. X            buf[count] = NULL;
  552. X            getyx(r_win, y, x);
  553. X            x--;
  554. X            wmove(r_win, y, x);
  555. X            waddch(r_win, ' ');
  556. X            wmove(r_win, y, x);
  557. X            wrefresh(r_win);
  558. X            continue;
  559. X        }
  560. X                    /* non-number after number is error */
  561. X        if (count) {
  562. X            beep();
  563. X            continue;
  564. X        }
  565. X                    /* prompt for LD codes */
  566. X        switch (ans) {
  567. X            case '+':
  568. X                if ((ld = prompt_ld(r_win, param->ld_plus, ans)) != NULL) {
  569. X                    free_ptr(param->ld_plus);
  570. X                    param->ld_plus = strdup(ld);
  571. X                    param_flag++;
  572. X                }
  573. X                break;
  574. X            case '-':
  575. X                if ((ld = prompt_ld(r_win, param->ld_minus, ans)) != NULL) {
  576. X                    free_ptr(param->ld_minus);
  577. X                    param->ld_minus = strdup(ld);
  578. X                    param_flag++;
  579. X                }
  580. X                break;
  581. X            case '@':
  582. X                if ((ld = prompt_ld(r_win, param->ld_at, ans)) != NULL) {
  583. X                    free_ptr(param->ld_at);
  584. X                    param->ld_at = strdup(ld);
  585. X                    param_flag++;
  586. X                }
  587. X                break;
  588. X            case '#':
  589. X                if ((ld = prompt_ld(r_win, param->ld_pound, ans)) != NULL) {
  590. X                    free_ptr(param->ld_pound);
  591. X                    param->ld_pound = strdup(ld);
  592. X                    param_flag++;
  593. X                }
  594. X                break;
  595. X            default:
  596. X                beep();
  597. X                continue;
  598. X        }
  599. X        break;
  600. X    }
  601. X                    /* if nothing changed */
  602. X    if (!param_flag && !dir_flag) {
  603. X        delwin(r_win);
  604. X        return(0);
  605. X    }
  606. X                    /* save to disk ? */
  607. X    clear_line(r_win, 4, 4, 1);
  608. X    if (dir_flag) {
  609. X        sprintf(buf, "Save entry %d to disk", num);
  610. X        save = yes_prompt(r_win, 4, 4, A_BOLD, buf);
  611. X    }
  612. X    else
  613. X        save = yes_prompt(r_win, 4, 4, A_BOLD, "Save to disk");
  614. X
  615. X                    /* update the files */
  616. X    if (save && dir_flag) {
  617. X        if (update_dir(num)) {
  618. X            touchwin(r_win);
  619. X            wrefresh(r_win);
  620. X        }
  621. X    }
  622. X    if (save && param_flag) {
  623. X        if (update_param()) {
  624. X            touchwin(r_win);
  625. X            wrefresh(r_win);
  626. X        }
  627. X    }
  628. X    delwin(r_win);
  629. X    return(1);
  630. X}
  631. X
  632. X/*
  633. X * Prompt for long distance code changes.  If new string is a space,
  634. X * change it to a null pointer.  Returns the new value or NULL on escape.
  635. X */
  636. X
  637. Xchar *
  638. Xprompt_ld(win, current_ld, name)
  639. XWINDOW *win;
  640. Xchar *current_ld, name;
  641. X{
  642. X    char *ans, *get_str();
  643. X    extern char *null_ptr;
  644. X
  645. X    werase(win);
  646. X    mvwprintw(win, 2, 4, "%-20.20s", current_ld);
  647. X    mvwprintw(win, 4, 4, "New LD code for %c: ", name);
  648. X    box(win, '|', '-');
  649. X    wrefresh(win);
  650. X
  651. X    if ((ans = get_str(win, 20, NULL, NULL)) == NULL)
  652. X        return(NULL);
  653. X                    /* if space, change to NULL pointer */
  654. X    if (!strcmp(ans, " "))
  655. X        ans = null_ptr;
  656. X                    /* display new value */
  657. X    clear_line(win, 2, 4, 1);
  658. X    wattrstr(win, A_BOLD, ans);
  659. X
  660. X    return(ans);
  661. X}
  662. SHAR_EOF
  663. if test 3971 -ne "`wc -c < 'd_revise.c'`"
  664. then
  665.     echo shar: "error transmitting 'd_revise.c'" '(should have been 3971 characters)'
  666. fi
  667. fi
  668. echo shar: "extracting 'data_log.c'" '(1840 characters)'
  669. if test -f 'data_log.c'
  670. then
  671.     echo shar: "will not over-write existing file 'data_log.c'"
  672. else
  673. sed 's/^X//' << \SHAR_EOF > 'data_log.c'
  674. X/*
  675. X * Open a window to prompt for a path name to be used for the data logging
  676. X * feature.  Turns on the data logging by killing the input routine and
  677. X * restarting it.  A return code of 1 means we need to restart the input
  678. X * routine.
  679. X */
  680. X
  681. X#include <stdio.h>
  682. X#include <curses.h>
  683. X#include "misc.h"
  684. X#include "param.h"
  685. X#include "status.h"
  686. X
  687. Xint
  688. Xdata_logging(fd)
  689. Xint fd;
  690. X{
  691. X    int ret_code;
  692. X    WINDOW *dl_win, *newwin();
  693. X    char *ans, *path, *expand(), *get_str(), *strdup();
  694. X    void input_off(), free_ptr();
  695. X    extern char *null_ptr;
  696. X
  697. X    dl_win = newwin(6, 70, 5, 5);
  698. X
  699. X    mvwprintw(dl_win, 2, 4, "Default log file: %s", param->logfile);
  700. X    mvwaddstr(dl_win, 3, 4, "New log file: ");
  701. X    box(dl_win, '|', '-');
  702. X
  703. X    mvwattrstr(dl_win, 0, 3, A_BOLD, " Start Data Logging ");
  704. X    wmove(dl_win, 3, 18);
  705. X    wrefresh(dl_win);
  706. X                    /* get the path */
  707. X    ret_code = 0;
  708. X    path = null_ptr;
  709. X    while ((ans = get_str(dl_win, 60, NULL, "     ")) != NULL) {
  710. X                    /* give 'em the default */
  711. X        if (*ans == NULL)
  712. X            path = strdup(param->logfile);
  713. X        else
  714. X            path = expand(ans);
  715. X
  716. X                    /* test write permission */
  717. X        if (can_write(path)) {
  718. X            ret_code++;
  719. X            break;
  720. X        }
  721. X
  722. X        beep();
  723. X        mvwattrstr(dl_win, 4, 24, A_BOLD, "No write permission");
  724. X        wrefresh(dl_win);
  725. X        wait_key(dl_win, 3);
  726. X                    /* cleanup the mess */
  727. X        clear_line(dl_win, 3, 18, 1);
  728. X        clear_line(dl_win, 4, 24, 1);
  729. X        wmove(dl_win, 3, 18);
  730. X        wrefresh(dl_win);
  731. X    }
  732. X    if (ret_code) {
  733. X        /*
  734. X         * Killing and then restarting the input routine is the
  735. X         * only way to change the name of the file that the input
  736. X         * routines uses.  It also assures that the 'status->log'
  737. X         * flag is in sync with the flag in the input routine.
  738. X         */
  739. X        input_off();
  740. X        status->log = 1;
  741. X        free_ptr(status->log_path);
  742. X        status->log_path = strdup(path);
  743. X    }
  744. X    if (fd == -1) {
  745. X        werase(dl_win);
  746. X        wrefresh(dl_win);
  747. X    }
  748. X    delwin(dl_win);
  749. X
  750. X    free_ptr(path);
  751. X    return(ret_code);
  752. X}
  753. SHAR_EOF
  754. if test 1840 -ne "`wc -c < 'data_log.c'`"
  755. then
  756.     echo shar: "error transmitting 'data_log.c'" '(should have been 1840 characters)'
  757. fi
  758. fi
  759. echo shar: "extracting 'di_delay.c'" '(1941 characters)'
  760. if test -f 'di_delay.c'
  761. then
  762.     echo shar: "will not over-write existing file 'di_delay.c'"
  763. else
  764. sed 's/^X//' << \SHAR_EOF > 'di_delay.c'
  765. X/*
  766. X * Prompt for new delay times during a dialing session.  Also, prompts
  767. X * if changes should be saved to disk.  Dialing is suspended during
  768. X * this routine.
  769. X */
  770. X
  771. X#include <stdio.h>
  772. X#include <curses.h>
  773. X#include "misc.h"
  774. X#include "param.h"
  775. X
  776. Xvoid
  777. Xdelay_times()
  778. X{
  779. X    WINDOW *dt_win, *newwin();
  780. X    int cdelay, pause;
  781. X
  782. X    dt_win = newwin(9, 45, 7, 15);
  783. X
  784. X    mvwprintw(dt_win, 2, 4, "Current carrier delay time: %d", param->cdelay);
  785. X    mvwprintw(dt_win, 3, 4, "Current pause between redials: %d", param->pause);
  786. X    mvwaddstr(dt_win, 5, 4, "New carrier delay: ");
  787. X    mvwaddstr(dt_win, 6, 4, "New pause time: ");
  788. X    box(dt_win, '|', '-');
  789. X
  790. X    mvwattrstr(dt_win, 0, 3, A_BOLD, " Change delay times ");
  791. X    wmove(dt_win, 5, 23);
  792. X    wrefresh(dt_win);
  793. X                    /* get the cdelay number */
  794. X    if ((cdelay = get_num(dt_win, 3)) == -1) {
  795. X        delwin(dt_win);
  796. X        return;
  797. X    }
  798. X                    /* give 'em the current settings */
  799. X    if (!cdelay) {
  800. X        cdelay = param->cdelay;
  801. X        wprintw(dt_win, "%-3d", cdelay);
  802. X    }
  803. X    else {
  804. X                    /* some reasonable limit */
  805. X        if (cdelay > MAX_CDELAY || cdelay < MIN_CDELAY) {
  806. X            beep();
  807. X            if (cdelay > MAX_CDELAY)
  808. X                cdelay = MAX_CDELAY;
  809. X            else
  810. X                cdelay = MIN_CDELAY;
  811. X            mvwprintw(dt_win, 5, 23, "%-3d", cdelay);
  812. X        }
  813. X    }
  814. X                    /* get the pause number */
  815. X    wmove(dt_win, 6, 20);
  816. X    wrefresh(dt_win);
  817. X    if ((pause = get_num(dt_win, 3)) == -1) {
  818. X        delwin(dt_win);
  819. X        return;
  820. X    }
  821. X                    /* give 'em the current settings */
  822. X    if (!pause) {
  823. X        pause = param->pause;
  824. X        wprintw(dt_win, "%-3d", pause);
  825. X    }
  826. X    else {
  827. X                    /* some reasonable limit */
  828. X        if (pause > MAX_PAUSE || pause < MIN_PAUSE) {
  829. X            beep();
  830. X            if (pause > MAX_PAUSE)
  831. X                pause = MAX_PAUSE;
  832. X            else
  833. X                pause = MIN_PAUSE;
  834. X            mvwprintw(dt_win, 6, 20, "%-3d", pause);
  835. X        }
  836. X    }
  837. X                    /* set 'em */
  838. X    param->cdelay = cdelay;
  839. X    param->pause = pause;
  840. X                    /* save 'em to disk ? */
  841. X    if (yes_prompt(dt_win, 7, 12, A_BOLD, "Save to disk")) {
  842. X        if (update_param()) {
  843. X            touchwin(dt_win);
  844. X            wrefresh(dt_win);
  845. X        }
  846. X    }
  847. X
  848. X    delwin(dt_win);
  849. X    return;
  850. X}
  851. SHAR_EOF
  852. if test 1941 -ne "`wc -c < 'di_delay.c'`"
  853. then
  854.     echo shar: "error transmitting 'di_delay.c'" '(should have been 1941 characters)'
  855. fi
  856. fi
  857. echo shar: "extracting 'di_win.c'" '(9254 characters)'
  858. if test -f 'di_win.c'
  859. then
  860.     echo shar: "will not over-write existing file 'di_win.c'"
  861. else
  862. sed 's/^X//' << \SHAR_EOF > 'di_win.c'
  863. X/*
  864. X * The dialing window routines.
  865. X */
  866. X
  867. X#define MAX_PASS 25
  868. X
  869. X#include <stdio.h>
  870. X#include <curses.h>
  871. X#include <signal.h>
  872. X#include <setjmp.h>
  873. X#include "dial_dir.h"
  874. X#include "misc.h"
  875. X#include "modem.h"
  876. X#include "param.h"
  877. X#include "status.h"
  878. X
  879. X/*
  880. X * The dialing window.  Its job is to kill the input routine, get a port,
  881. X * cycle thru the entries in the queue, while interpreting both the
  882. X * user's requests and the modem's responses.  A return code of 1 means
  883. X * we're ready to fire up the input mode.
  884. X */
  885. X
  886. Xint
  887. Xdial_win()
  888. X{
  889. X    WINDOW *di_win, *newwin();
  890. X    int i, j, ans, want_out, pass, tic, baud, modem_sync;
  891. X    long now, time();
  892. X    char *tbuf, *ctime(), *str, cr=13, *monitor_dial();
  893. X    void disp_queue(), send_str(), dial_it(), delay_times(), input_off();
  894. X    void error_win(), status_line(), line_set(), hang_up();
  895. X    extern int rc_index;
  896. X    unsigned int sleep();
  897. X                    /* are we already talking? */
  898. X    input_off();
  899. X    hang_up(1);
  900. X
  901. X    if (get_port())
  902. X        return(0);
  903. X    /*
  904. X     * If the phone number is a NULL, then either we are on a
  905. X     * direct line, or you want to do the dialing yourself.
  906. X     */
  907. X    if (*dir->number[dir->q_num[0]] == NULL) {
  908. X                    /* check LD permission */
  909. X        if (limit_ld(0))
  910. X            return(0);
  911. X                    /* can't talk directly to OBM */
  912. X        if (!strcmp(modem->mname[modem->m_cur], "OBM")) {
  913. X            error_win(0, "Can't access the line directly.", "Use the automatic dialing feature");
  914. X            return(0);
  915. X        }
  916. X        unlink(status->vs_path);
  917. X        touchwin(stdscr);
  918. X        clear();
  919. X        printw("Connected to %s at %d baud...\n", modem->tty[modem->t_cur], dir->baud[dir->d_cur]);
  920. X        refresh();
  921. X        return(1);
  922. X    }
  923. X
  924. X    di_win = newwin(17, 70, 3, 5);
  925. X                    /* the basic window */
  926. X    mvwattrstr(di_win, 1, 20, A_BOLD, "D I A L I N G       W I N D O W");
  927. X    mvwaddstr(di_win, 2, 0, "---------------------------------------------------------------------");
  928. X    mvwaddstr(di_win, 4, 23, "System name:");
  929. X    mvwaddstr(di_win, 5, 23, "Pass number:");
  930. X    mvwaddstr(di_win, 6, 14, "Elapse time this try:");
  931. X    mvwaddstr(di_win, 7, 13, "Time at start of dial:");
  932. X    mvwaddstr(di_win, 8, 9, "Time at start of this try:");
  933. X    mvwaddstr(di_win, 9, 16, "Connect delay time:");
  934. X    mvwaddstr(di_win, 10, 15, "Pause between tries:");
  935. X    mvwaddstr(di_win, 11, 25, "Index/tty:");
  936. X    mvwaddstr(di_win, 12, 16, "Result of last try:");
  937. X
  938. X    mvwaddstr(di_win, 14, 3, "SPACE: Recycle");
  939. X    mvwaddstr(di_win, 14, 21, "DEL: Remove from queue");
  940. X    mvwaddstr(di_win, 14, 46, "E: Change delay times");
  941. X
  942. X                    /* the start time */
  943. X    time(&now);
  944. X    tbuf = ctime(&now);
  945. X    tbuf[19] = NULL;
  946. X    mvwaddstr(di_win, 7, 36, &tbuf[11]);
  947. X
  948. X    mvwprintw(di_win, 9, 36, "%-4d", param->cdelay);
  949. X    mvwprintw(di_win, 10, 36, "%-4d", param->pause);
  950. X
  951. X    box(di_win, '|', '-');
  952. X    mvwaddstr(di_win, 16, 25, " Press ESC to abort ");
  953. X
  954. X    pass = 0;
  955. X    i = 0;
  956. X    want_out = 0;
  957. X    while (!want_out && pass <= MAX_PASS) {
  958. X        ans = -1;
  959. X        pass++;
  960. X                    /* update the d_cur variable */
  961. X        dir->d_cur = dir->q_num[i];
  962. X                    /* check LD permission */
  963. X        if (limit_ld(i))
  964. X            return(0);
  965. X                    /* get a port */
  966. X        if (get_port())
  967. X            return(0);
  968. X                    /* can the modem sync baud rates ? */
  969. X        modem_sync = can_sync();
  970. X                    /* fill in the window */
  971. X        disp_queue(di_win, dir->d_cur, pass);
  972. X
  973. X        /*
  974. X         * The actual dial routine. The 'i' is the index into the
  975. X         * queue, not the entry number.  Returns immediately without
  976. X         * waiting for a carrier.
  977. X         */
  978. X        dial_it(i);
  979. X        ioctl(status->fd, TCFLSH, 0);
  980. X
  981. X        /*
  982. X         * Here we do a time-slice between reading the result codes
  983. X         * from the modem and reading the keyboard.  The one second
  984. X         * granularity won't be too accurate, but who cares?
  985. X         */
  986. X        tic = 0;
  987. X        rc_index = 0;
  988. X        while (tic < param->cdelay) {
  989. X            if (!(str = monitor_dial())) {
  990. X                mvwprintw(di_win, 6, 36, "%-4d", ++tic);
  991. X                wrefresh(di_win);
  992. X            }
  993. X            else {
  994. X                /*
  995. X                 * A return code that converts to an number
  996. X                 * that is less than 300 is probably an error
  997. X                 * message.
  998. X                 */
  999. X                baud = atoi(str);
  1000. X                if (baud < 300) {
  1001. X                    mvwprintw(di_win, 12, 36, "%-20.20s", str);
  1002. X                    wmove(di_win, 12, 36);
  1003. X                    wrefresh(di_win);
  1004. X                    break;
  1005. X                }
  1006. X                    /* we're connected */
  1007. X                beep();
  1008. X                clear_line(di_win, 12, 36, 1);
  1009. X                wattrstr(di_win, A_BLINK, "CONNECTED");
  1010. X                wmove(di_win, 12, 36);
  1011. X                wrefresh(di_win);
  1012. X                wait_key(di_win, 2);
  1013. X                delwin(di_win);
  1014. X
  1015. X                /*
  1016. X                 * Did the modem sync at a different baud
  1017. X                 * rate than what we expected?
  1018. X                 */
  1019. X                if (modem_sync) {
  1020. X                    if (dir->baud[dir->d_cur] != baud) {
  1021. X                        dir->baud[dir->d_cur] = baud;
  1022. X                        line_set();
  1023. X                    }
  1024. X                }
  1025. X
  1026. X                unlink(status->vs_path);
  1027. X                touchwin(stdscr);
  1028. X                clear();
  1029. X                printw("Connected to %s at %d baud...\n",
  1030. X                 dir->name[dir->d_cur], dir->baud[dir->d_cur]);
  1031. X                refresh();
  1032. X
  1033. X                    /* log the call */
  1034. X                log_calls(i);
  1035. X                return(1);
  1036. X            }
  1037. X            if (tic == param->cdelay)
  1038. X                break;
  1039. X                    /* ok... try the keyboard */
  1040. X            if ((ans = wait_key(di_win, 1)) != -1)
  1041. X                break;
  1042. X
  1043. X            mvwprintw(di_win, 6, 36, "%-4d", ++tic);
  1044. X            wrefresh(di_win);
  1045. X        }
  1046. X        /*
  1047. X         * If the modem did not return a code, then we need to
  1048. X         * stop it.  Sending a CR will stop most modems cold,
  1049. X         * except of course for the OBM...
  1050. X         */
  1051. X        if (str == NULL) {
  1052. X            if (!strcmp(modem->mname[modem->m_cur], "OBM"))
  1053. X                hang_up(0);
  1054. X            else
  1055. X                write(status->fd, &cr, 1);
  1056. X            sleep(1);
  1057. X        }
  1058. X                    /* if we get here, no key was pressed */
  1059. X        if (ans == -1) {
  1060. X            clear_line(di_win, 6, 14, 1);
  1061. X            mvwaddstr(di_win, 6, 27, "Pausing:");
  1062. X                    /* no return code ? */
  1063. X            if (str == NULL) {
  1064. X                clear_line(di_win, 12, 36, 1);
  1065. X                waddstr(di_win, "TIMED OUT");
  1066. X                wmove(di_win, 12, 36);
  1067. X            }
  1068. X                    /* do the pause */
  1069. X            tic = 0;
  1070. X            while (tic < param->pause) {
  1071. X                if ((ans = wait_key(di_win, 1)) != -1)
  1072. X                    break;
  1073. X                mvwprintw(di_win, 6, 36, "%-4d", ++tic);
  1074. X                wrefresh(di_win);
  1075. X            }
  1076. X            clear_line(di_win, 6, 14, 1);
  1077. X            waddstr(di_win, "Elapse time this try:");
  1078. X        }
  1079. X                    /* Process the keystroke */
  1080. X        switch(ans) {
  1081. X            case ' ':    /* next in the queue */
  1082. X                clear_line(di_win, 12, 36, 1);
  1083. X                waddstr(di_win, "RECYCLED");
  1084. X                wmove(di_win, 12, 36);
  1085. X                wrefresh(di_win);
  1086. X                /* fall thru... */
  1087. X            case -1:    /* no key was pressed */
  1088. X                i++;
  1089. X                if (i > NUM_QUEUE)
  1090. X                    i = 0;
  1091. X                if (dir->q_num[i] == -1)
  1092. X                    i = 0;
  1093. X                break;
  1094. X            case 127:    /* DEL key, remove from queue */
  1095. X                if (dir->q_num[1] == -1) {
  1096. X                    beep();
  1097. X                    clear_line(di_win, 12, 36, 1);
  1098. X                    waddstr(di_win, "NO MORE ENTRIES");
  1099. X                    wmove(di_win, 12, 36);
  1100. X                    wrefresh(di_win);
  1101. X                    wait_key(di_win, 3);
  1102. X                    break;
  1103. X                }
  1104. X                clear_line(di_win, 12, 36, 1);
  1105. X                waddstr(di_win, "ENTRY DELETED");
  1106. X                wmove(di_win, 12, 36);
  1107. X                wrefresh(di_win);
  1108. X                wait_key(di_win, 3);
  1109. X
  1110. X                    /* compact the queue */
  1111. X                for (j=i; j<NUM_QUEUE-1; j++)
  1112. X                    dir->q_num[j] = dir->q_num[j+1];
  1113. X                dir->q_num[NUM_QUEUE-1] = -1;
  1114. X                break;
  1115. X            case 'e':
  1116. X            case 'E':    /* change delay time */
  1117. X                delay_times();
  1118. X                touchwin(di_win);
  1119. X                mvwprintw(di_win, 9, 36, "%-4d", param->cdelay);
  1120. X                mvwprintw(di_win, 10, 36, "%-4d", param->pause);
  1121. X                break;
  1122. X            case 27:    /* ESC key */
  1123. X                beep();
  1124. X                clear_line(di_win, 12, 36, 1);
  1125. X                wattrstr(di_win, A_BLINK, "DIAL ABORTED");
  1126. X                wmove(di_win, 12, 36);
  1127. X                wrefresh(di_win);
  1128. X                wait_key(di_win, 3);
  1129. X                want_out++;
  1130. X                break;
  1131. X            default:
  1132. X                beep();
  1133. X                break;
  1134. X        }
  1135. X    }
  1136. X                    /* clean up and go home */
  1137. X    werase(di_win);
  1138. X    wrefresh(di_win);
  1139. X    delwin(di_win);
  1140. X    if (!want_out)
  1141. X        error_win(0, "Exceeded the maximum number number of dialing attempts", NULL);
  1142. X    return(0);
  1143. X}
  1144. X
  1145. X/*
  1146. X * Display what info we know at this time.
  1147. X */
  1148. X
  1149. Xvoid
  1150. Xdisp_queue(win, entry, pass)
  1151. XWINDOW *win;
  1152. Xint entry, pass;
  1153. X{
  1154. X    long now, time();
  1155. X    char *tbuf, *ctime();
  1156. X    void status_line();
  1157. X                    /* redo the status line */
  1158. X    status_line(NULL);
  1159. X                    /* system name */
  1160. X    clear_line(win, 4, 36, 1);
  1161. X    waddstr(win, dir->name[entry]);
  1162. X                    /* pass number */
  1163. X    mvwprintw(win, 5, 36, "%-4d", pass);
  1164. X                    /* time of this call */
  1165. X    time(&now);
  1166. X    tbuf = ctime(&now);
  1167. X    tbuf[19] = NULL;
  1168. X    mvwaddstr(win, 8, 36, &tbuf[11]);
  1169. X                    /* the index field */    
  1170. X    clear_line(win, 11, 36, 1);
  1171. X    waddstr(win, dir->index[entry]);
  1172. X
  1173. X    wmove(win, 12, 36);
  1174. X    wrefresh(win);
  1175. X    return;
  1176. X}
  1177. X
  1178. X/*
  1179. X * Monitor the progress of the dialing, but returns a NULL after one
  1180. X * second of inactivity.
  1181. X */
  1182. X
  1183. Xjmp_buf md_jmp;
  1184. X
  1185. Xchar *
  1186. Xmonitor_dial()
  1187. X{
  1188. X    int force_md();
  1189. X    char *ans, *read_codes();
  1190. X    unsigned int alarm();
  1191. X
  1192. X    if (setjmp(md_jmp))
  1193. X        return(NULL);
  1194. X    signal(SIGALRM, force_md);
  1195. X    alarm(1);
  1196. X    ans = read_codes();
  1197. X    alarm(0);
  1198. X    return(ans);
  1199. X}
  1200. Xint
  1201. Xforce_md(dummy)
  1202. Xint dummy;
  1203. X{
  1204. X    void longjmp();
  1205. X
  1206. X    longjmp(md_jmp, 1);
  1207. X}
  1208. X
  1209. X/*
  1210. X * Determine if the modem can detect the synchronization of the baud
  1211. X * rate if it's different that what it expects.  To do this, we check
  1212. X * to see if any two connect strings are the same.  A return code of
  1213. X * 1 means the modem can sync.
  1214. X */
  1215. X
  1216. Xint
  1217. Xcan_sync()
  1218. X{
  1219. X    int i;
  1220. X
  1221. X    i = modem->m_cur;
  1222. X                    /* not both null (sneaky trick) */
  1223. X    if (*modem->con_3[i] + *modem->con_12[i]) {
  1224. X        if (!strcmp(modem->con_3[i], modem->con_12[i]))
  1225. X            return(0);
  1226. X    }
  1227. X    if (*modem->con_12[i] + *modem->con_24[i]) {
  1228. X        if (!strcmp(modem->con_12[i], modem->con_24[i]))
  1229. X            return(0);
  1230. X    }
  1231. X    if (*modem->con_24[i] + *modem->con_48[i]) {
  1232. X        if (!strcmp(modem->con_24[i], modem->con_48[i]))
  1233. X            return(0);
  1234. X    }
  1235. X    if (*modem->con_48[i] + *modem->con_96[i]) {
  1236. X        if (!strcmp(modem->con_48[i], modem->con_96[i]))
  1237. X            return(0);
  1238. X    }
  1239. X    if (*modem->con_96[i] + *modem->con_192[i]) {
  1240. X        if (!strcmp(modem->con_96[i], modem->con_192[i]))
  1241. X            return(0);
  1242. X    }
  1243. X    return(1);
  1244. X}
  1245. SHAR_EOF
  1246. if test 9254 -ne "`wc -c < 'di_win.c'`"
  1247. then
  1248.     echo shar: "error transmitting 'di_win.c'" '(should have been 9254 characters)'
  1249. fi
  1250. fi
  1251. echo shar: "extracting 'dial.c'" '(6478 characters)'
  1252. if test -f 'dial.c'
  1253. then
  1254.     echo shar: "will not over-write existing file 'dial.c'"
  1255. else
  1256. sed 's/^X//' << \SHAR_EOF > 'dial.c'
  1257. X/*
  1258. X * The routines that dial the modem and listen for the return codes.
  1259. X */
  1260. X
  1261. X#include <stdio.h>
  1262. X#include <termio.h>
  1263. X#ifdef UNIXPC
  1264. X#include <sys/phone.h>
  1265. X#endif /* UNIXPC */
  1266. X#include "dial_dir.h"
  1267. X#include "modem.h"
  1268. X#include "param.h"
  1269. X#include "status.h"
  1270. X
  1271. X/*
  1272. X * Get the dial string ready, send it to the modem.  The parameter is not
  1273. X * the actual entry number, it is an index into the queue.
  1274. X */
  1275. X
  1276. Xvoid
  1277. Xdial_it(num)
  1278. Xint num;
  1279. X{
  1280. X    int i;
  1281. X    char s[100], number[40], *strcpy(), *strcat(), *n, *strchr();
  1282. X    void send_str();
  1283. X#ifdef UNIXPC
  1284. X    struct updata pbuf;
  1285. X    unsigned int sleep();
  1286. X#endif /* UNIXPC */
  1287. X
  1288. X    /*
  1289. X     * Create the string to be sent to the modem.  The long distance
  1290. X     * codes are added if they are requested.
  1291. X     */
  1292. X    s[0] = NULL;
  1293. X    strcpy(s, modem->dial[modem->m_cur]);
  1294. X
  1295. X    switch (dir->q_ld[num]) {
  1296. X        case 0:            /* no ld code requested */
  1297. X            break;
  1298. X        case '+':
  1299. X            strcat(s, param->ld_plus);
  1300. X            break;
  1301. X        case '-':
  1302. X            strcat(s, param->ld_minus);
  1303. X            break;
  1304. X        case '@':
  1305. X            strcat(s, param->ld_at);
  1306. X            break;
  1307. X        case '#':
  1308. X            strcat(s, param->ld_pound);
  1309. X            break;
  1310. X    }
  1311. X    /*
  1312. X     * Purify the phone number by removing all the pretty characters
  1313. X     * that don't need to be sent to the modem.  Typically the '-',
  1314. X     * '(', ')', and space characters are just for looks.
  1315. X     */
  1316. X    i = 0;
  1317. X    n = dir->number[dir->q_num[num]];
  1318. X    while (*n) {
  1319. X        if (!strchr("-() ", *n))
  1320. X            number[i++] = *n;
  1321. X        n++;
  1322. X    }
  1323. X    number[i] = NULL;
  1324. X                    /* add it to the string */
  1325. X    strcat(s, number);
  1326. X    strcat(s, modem->suffix[modem->m_cur]);
  1327. X
  1328. X#ifdef UNIXPC
  1329. X                    /* special case for OBM */
  1330. X    if (!strcmp(modem->mname[modem->m_cur], "OBM")) {
  1331. X                    /* prepare the modem */
  1332. X        pbuf.c_lineparam = DATA|DTMF;
  1333. X        pbuf.c_waitdialtone = 5;
  1334. X        pbuf.c_linestatus = 0;
  1335. X        pbuf.c_feedback = SPEAKERON|NORMSPK;
  1336. X        pbuf.c_waitflash = 500;
  1337. X        ioctl(status->fd, PIOCSETP, &pbuf);
  1338. X
  1339. X                    /* connect the dialer */
  1340. X        ioctl(status->fd, PIOCRECONN);
  1341. X        sleep(1);
  1342. X                    /* dial each digit */
  1343. X        n = s;
  1344. X        while(*n) {
  1345. X                    /* switch tone/pulse dialing ? */
  1346. X            switch(*n) {
  1347. X                case '^':
  1348. X                    pbuf.c_lineparam = DATA|PULSE;
  1349. X                    ioctl(status->fd, PIOCSETP, &pbuf);
  1350. X                    break;
  1351. X                case '%':
  1352. X                    pbuf.c_lineparam = DATA|DTMF;
  1353. X                    ioctl(status->fd, PIOCSETP, &pbuf);
  1354. X                    break;
  1355. X                default:
  1356. X                    ioctl(status->fd, PIOCDIAL, n);
  1357. X                    break;
  1358. X            }
  1359. X            n++;
  1360. X        }
  1361. X    }
  1362. X
  1363. X#else /* UNIXPC */
  1364. X    send_str(s);
  1365. X#endif /* UNIXPC */
  1366. X    return;
  1367. X}
  1368. X
  1369. X/*
  1370. X * Send a string to the modem.  Performs all the character synonym
  1371. X * translations.  No sanity checking on the "m_cur" value.
  1372. X */
  1373. X
  1374. Xvoid
  1375. Xsend_str(s)
  1376. Xchar *s;
  1377. X{
  1378. X    int skip;
  1379. X    char c;
  1380. X    unsigned int sleep();
  1381. X                    /* empty string ?? */
  1382. X    if (s == NULL || *s == NULL)
  1383. X        return;
  1384. X
  1385. X    ioctl(status->fd, TCFLSH, 1);    
  1386. X    /*
  1387. X     * Change the character synonyms to their real values.  Writes
  1388. X     * the characters to the modem.  To remove the special meaning
  1389. X     * of one of the characters, prepend a '\' to it.
  1390. X     */
  1391. X    skip = 0;
  1392. X    while (*s) {
  1393. X        c = *s;
  1394. X                    /* send the literal character */
  1395. X        if (skip) {
  1396. X            skip = 0;
  1397. X            write(status->fd, &c, 1);
  1398. X            ioctl(status->fd, TCSBRK, 1);
  1399. X            s++;
  1400. X            continue;
  1401. X        }
  1402. X                    /* turn off the special meaning */
  1403. X        if (c == '\\') {
  1404. X            skip = 1;
  1405. X            s++;
  1406. X            continue;
  1407. X        }
  1408. X                    /* carriage return synonym */
  1409. X        if (c == param->cr_char)
  1410. X            c = '\r';
  1411. X                    /* 2 character control sequence */
  1412. X        if (c == param->ctrl_char) {
  1413. X            s++;
  1414. X            c = *s;
  1415. X                    /* premature EOF? */
  1416. X            if (c == NULL)
  1417. X                break;
  1418. X            if (c > '_')
  1419. X                c -= 96;
  1420. X            else
  1421. X                c -= 64;
  1422. X        }
  1423. X                    /* escape synonym */
  1424. X        if (c == param->esc_char)
  1425. X            c = 27;
  1426. X                    /* pause synonym */
  1427. X        if (c == param->pause_char) {
  1428. X            sleep(1);
  1429. X            s++;
  1430. X            continue;
  1431. X        }
  1432. X        write(status->fd, &c, 1);
  1433. X        /*
  1434. X         * Because the pause char makes the timing critical, we
  1435. X         * wait until the buffer is clear before we continue.
  1436. X         */
  1437. X        ioctl(status->fd, TCSBRK, 1);
  1438. X        s++;
  1439. X    }
  1440. X    return;
  1441. X}
  1442. X
  1443. X/*
  1444. X * Read the result codes coming back from the modem.  Test for the 6
  1445. X * "connect" strings and the 4 "no connect" strings.  Return the connected
  1446. X * baud rate (as a string) or the error message.
  1447. X */
  1448. X
  1449. Xchar rc_buf[512];
  1450. Xint rc_index;
  1451. X
  1452. Xchar *
  1453. Xread_codes()
  1454. X{
  1455. X    char c;
  1456. X#ifdef UNIXPC
  1457. X    unsigned int sleep();
  1458. X    struct updata pbuf;
  1459. X                    /* special case for OBM */
  1460. X    if (!strcmp(modem->mname[modem->m_cur], "OBM")) {
  1461. X        ioctl(status->fd, PIOCGETP, &pbuf);
  1462. X
  1463. X                    /* fake the return code */
  1464. X        if (pbuf.c_linestatus & MODEMCONNECTED)
  1465. X            return("1200");
  1466. X
  1467. X        sleep(1);
  1468. X        return(NULL);
  1469. X    }
  1470. X#endif /* UNIXPC */
  1471. X                    /* search for key words */
  1472. X    for (; rc_index<511; rc_index++) {
  1473. X        if (read(status->fd, &c, 1) <= 0)
  1474. X            return(NULL);
  1475. X
  1476. X        rc_buf[rc_index] = c;
  1477. X        rc_buf[rc_index+1] = NULL;
  1478. X                    /* the connect strings */
  1479. X        if (match(rc_buf, modem->con_3[modem->m_cur]))
  1480. X            return("300");
  1481. X
  1482. X        if (match(rc_buf, modem->con_12[modem->m_cur]))
  1483. X            return("1200");
  1484. X
  1485. X        if (match(rc_buf, modem->con_24[modem->m_cur]))
  1486. X            return("2400");
  1487. X
  1488. X        if (match(rc_buf, modem->con_48[modem->m_cur]))
  1489. X            return("4800");
  1490. X
  1491. X        if (match(rc_buf, modem->con_96[modem->m_cur]))
  1492. X            return("9600");
  1493. X
  1494. X        if (match(rc_buf, modem->con_192[modem->m_cur]))
  1495. X            return("19200");
  1496. X
  1497. X                    /* the no connect strings */
  1498. X        if (match(rc_buf, modem->no_con1[modem->m_cur]))
  1499. X            return(modem->no_con1[modem->m_cur]);
  1500. X
  1501. X        if (match(rc_buf, modem->no_con2[modem->m_cur]))
  1502. X            return(modem->no_con2[modem->m_cur]);
  1503. X
  1504. X        if (match(rc_buf, modem->no_con3[modem->m_cur]))
  1505. X            return(modem->no_con3[modem->m_cur]);
  1506. X
  1507. X        if (match(rc_buf, modem->no_con4[modem->m_cur]))
  1508. X            return(modem->no_con4[modem->m_cur]);
  1509. X    }
  1510. X                    /* ran out of buffer ? */
  1511. X    return("ERROR");
  1512. X}
  1513. X
  1514. X/*
  1515. X * Test for a match between two character strings.  A return code of 1
  1516. X * means that s2 was found at the end of s1
  1517. X */
  1518. X
  1519. Xint
  1520. Xmatch(s1, s2)
  1521. Xchar *s1, *s2;
  1522. X{
  1523. X    int i, skip, diff;
  1524. X    char c, new[40];
  1525. X                    /* if no string to match */
  1526. X    if (*s2 == NULL)
  1527. X        return(0);
  1528. X                    /* translate synonyms */
  1529. X    i = 0;
  1530. X    skip = 0;
  1531. X    while (*s2) {
  1532. X        c = *s2;
  1533. X                    /* literal character */
  1534. X        if (skip) {
  1535. X            skip = 0;
  1536. X            new[i++] = c;
  1537. X            s2++;
  1538. X            continue;
  1539. X        }
  1540. X                    /* turn off the special meaning */
  1541. X        if (c == '\\') {
  1542. X            skip = 1;
  1543. X            s2++;
  1544. X            continue;
  1545. X        }
  1546. X                    /* carriage return synonym */
  1547. X        if (c == param->cr_char)
  1548. X            c = '\r';
  1549. X
  1550. X                    /* 2 character control sequence */
  1551. X        if (c == param->ctrl_char) {
  1552. X            s2++;
  1553. X            c = *s2;
  1554. X            if (c == NULL)
  1555. X                break;
  1556. X            if (c > '_')
  1557. X                c -= 96;
  1558. X            else
  1559. X                c -= 64;
  1560. X        }
  1561. X                    /* escape synonym */
  1562. X        if (c == param->esc_char)
  1563. X            c = 27;
  1564. X
  1565. X        new[i++] = c;
  1566. X        s2++;
  1567. X    }
  1568. X    new[i] = NULL;
  1569. X
  1570. X    diff = strlen(s1) - strlen(new);
  1571. X                    /* is it possible ? */
  1572. X    if (diff < 0)
  1573. X        return(0);
  1574. X                    /* test it out */
  1575. X    if (!strcmp(&s1[diff], new))
  1576. X        return(1);
  1577. X    return(0);
  1578. X}
  1579. SHAR_EOF
  1580. if test 6478 -ne "`wc -c < 'dial.c'`"
  1581. then
  1582.     echo shar: "error transmitting 'dial.c'" '(should have been 6478 characters)'
  1583. fi
  1584. fi
  1585. echo shar: "extracting 'expand.c'" '(2396 characters)'
  1586. if test -f 'expand.c'
  1587. then
  1588.     echo shar: "will not over-write existing file 'expand.c'"
  1589. else
  1590. sed 's/^X//' << \SHAR_EOF > 'expand.c'
  1591. X/*
  1592. X * Do file name expansion with 'native' shell.  Using the native shell
  1593. X * (as described in the SHELL environmental variable) allows for csh or
  1594. X * ksh abbreviations that sh doesn't recognize.
  1595. X */
  1596. X
  1597. X#include <stdio.h>
  1598. X#include <signal.h>
  1599. X
  1600. Xchar *
  1601. Xexpand(input)
  1602. Xchar *input;
  1603. X{
  1604. X    FILE *pfp, *native_popen();
  1605. X    char *ans, buf[1024], *strpbrk(), *strdup();
  1606. X    extern char *null_ptr;
  1607. X    void free_ptr();
  1608. X
  1609. X                    /* same rules as strdup() */
  1610. X    if (input == NULL)
  1611. X        return(NULL);
  1612. X    if (*input == NULL)
  1613. X        return(null_ptr);
  1614. X                    /* any thing to expand ? */
  1615. X    ans = strdup(input);
  1616. X    if (!strpbrk(input, "$*{}[]\\?~"))
  1617. X        return(ans);
  1618. X                    /* popen an echo */
  1619. X    sprintf(buf, "echo %s", input);
  1620. X
  1621. X    pfp = native_popen(buf, "r");
  1622. X    fgets(buf, 1024, pfp);
  1623. X    native_pclose(pfp);
  1624. X
  1625. X    if (!strlen(buf))
  1626. X        return(ans);
  1627. X                    /* zap the line feed */
  1628. X    buf[strlen(buf)-1] = NULL;
  1629. X
  1630. X    free_ptr(ans);
  1631. X    ans = strdup(buf);
  1632. X    return(ans);
  1633. X}
  1634. X
  1635. X#define    tst(a,b) (*mode == 'r'? (b) : (a))
  1636. X#define    RDR    0
  1637. X#define    WTR    1
  1638. Xstatic int popen_pid[20];
  1639. X
  1640. XFILE *
  1641. Xnative_popen(cmd, mode)
  1642. Xchar *cmd, *mode;
  1643. X{
  1644. X    int myside, hisside, pid, p[2];
  1645. X    char *shellpath, *shell, *flags, *getenv(), *strrchr();
  1646. X    void _exit();
  1647. X
  1648. X    if (pipe(p) < 0)
  1649. X        return NULL;
  1650. X
  1651. X    myside = tst(p[WTR], p[RDR]);
  1652. X    hisside = tst(p[RDR], p[WTR]);
  1653. X                    /* get the environmental variable */
  1654. X    shellpath = getenv("SHELL");
  1655. X    if (shellpath == NULL || strlen(shellpath) == 0)
  1656. X        shellpath = "/bin/sh";
  1657. X
  1658. X    shell = strrchr(shellpath, '/') + 1;
  1659. X                    /* fix up the flags */
  1660. X    if (!strcmp(shell, "csh"))
  1661. X        flags = "-fc";
  1662. X    else
  1663. X        flags = "-c";        /* Korn shell too */
  1664. X
  1665. X    if (!(pid = fork())) {
  1666. X        int stdio;
  1667. X                    /* no error messages please */
  1668. X        close(2);
  1669. X#ifdef SGID
  1670. X        setgid(getgid());
  1671. X#endif /* SGID */
  1672. X        stdio = tst(0, 1);
  1673. X        close(myside);
  1674. X        close(stdio);
  1675. X        fcntl(hisside, 0, stdio);
  1676. X        close(hisside);
  1677. X        execl(shellpath, shell, flags, cmd, 0);
  1678. X        _exit(1);
  1679. X    }
  1680. X    if (pid == -1) {
  1681. X        close(myside);
  1682. X        close(hisside);
  1683. X        return NULL;
  1684. X    }
  1685. X
  1686. X    popen_pid[myside] = pid;
  1687. X
  1688. X    close(hisside);
  1689. X    return(fdopen(myside, mode));
  1690. X}
  1691. X
  1692. Xnative_pclose(ptr)
  1693. XFILE *ptr;
  1694. X{
  1695. X    int f, r, (*hstat)(), (*istat)(), (*qstat)(), status;
  1696. X
  1697. X    f = fileno(ptr);
  1698. X    fclose(ptr);
  1699. X    istat = signal(SIGINT, SIG_IGN);
  1700. X    qstat = signal(SIGQUIT, SIG_IGN);
  1701. X    hstat = signal(SIGHUP, SIG_IGN);
  1702. X
  1703. X    while ((r = wait(&status)) != popen_pid[f] && r != -1)
  1704. X        ;
  1705. X
  1706. X    if (r == -1)
  1707. X        status = -1;
  1708. X
  1709. X    signal(SIGINT, istat);
  1710. X    signal(SIGQUIT, qstat);
  1711. X    signal(SIGHUP, hstat);
  1712. X    return(status);
  1713. X}
  1714. SHAR_EOF
  1715. if test 2396 -ne "`wc -c < 'expand.c'`"
  1716. then
  1717.     echo shar: "error transmitting 'expand.c'" '(should have been 2396 characters)'
  1718. fi
  1719. fi
  1720. echo shar: "extracting 'getcwd.c'" '(382 characters)'
  1721. if test -f 'getcwd.c'
  1722. then
  1723.     echo shar: "will not over-write existing file 'getcwd.c'"
  1724. else
  1725. sed 's/^X//' << \SHAR_EOF > 'getcwd.c'
  1726. X/*
  1727. X * Can you believe it???  Masscomps don't have a function to return the
  1728. X * current working directory while in the AT&T universe!
  1729. X */
  1730. X
  1731. X#include <stdio.h>
  1732. X
  1733. Xchar *
  1734. Xgetcwd(buf, size)
  1735. Xchar *buf;
  1736. Xint size;
  1737. X{
  1738. X    FILE *pfp, *popen();
  1739. X
  1740. X    if (!(pfp = popen("pwd", "r")))
  1741. X        return(".");
  1742. X    
  1743. X    fgets(buf, size, pfp);
  1744. X    pclose(pfp);
  1745. X                    /* zap the NL */
  1746. X    buf[strlen(buf)-1] = NULL;
  1747. X    return(buf);
  1748. X}
  1749. SHAR_EOF
  1750. if test 382 -ne "`wc -c < 'getcwd.c'`"
  1751. then
  1752.     echo shar: "error transmitting 'getcwd.c'" '(should have been 382 characters)'
  1753. fi
  1754. fi
  1755. echo shar: "extracting 'getopt.c'" '(1034 characters)'
  1756. if test -f 'getopt.c'
  1757. then
  1758.     echo shar: "will not over-write existing file 'getopt.c'"
  1759. else
  1760. sed 's/^X//' << \SHAR_EOF > 'getopt.c'
  1761. X/*
  1762. X * Parse the command line and return option flags and arguments
  1763. X */
  1764. X
  1765. X#include <stdio.h>
  1766. X
  1767. Xint optind = 1;
  1768. Xchar *optarg;
  1769. X
  1770. Xint
  1771. Xgetopt(argc, argv, opts)
  1772. Xint argc;
  1773. Xchar *argv[];
  1774. Xchar *opts;
  1775. X{
  1776. X    static int sp = 1;
  1777. X    int c, strcmp();
  1778. X    char *cp, *strchr();
  1779. X
  1780. X    if (sp == 1) {
  1781. X        if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
  1782. X            return(EOF);
  1783. X        else if (strcmp(argv[optind], "--") == NULL) {
  1784. X            optind++;
  1785. X            return(EOF);
  1786. X        }
  1787. X    }
  1788. X    c = argv[optind][sp];
  1789. X    if (c == ':' || (cp=strchr(opts, c)) == NULL) {
  1790. X        fprintf(stderr, "%s: illegal option '%c'\n", argv[0], c);
  1791. X        if (argv[optind][++sp] == '\0') {
  1792. X            optind++;
  1793. X            sp = 1;
  1794. X        }
  1795. X        return('?');
  1796. X    }
  1797. X    if (*++cp == ':') {
  1798. X        if (argv[optind][sp+1] != '\0')
  1799. X            optarg = &argv[optind++][sp+1];
  1800. X        else if (++optind >= argc) {
  1801. X            fprintf(stderr, "%s: option '%c' requires an argument\n", argv[0], c);
  1802. X            sp = 1;
  1803. X            return('?');
  1804. X        } else
  1805. X            optarg = argv[optind++];
  1806. X        sp = 1;
  1807. X    } else {
  1808. X        if (argv[optind][++sp] == '\0') {
  1809. X            sp = 1;
  1810. X            optind++;
  1811. X        }
  1812. X        optarg = NULL;
  1813. X    }
  1814. X    return(c);
  1815. X}
  1816. SHAR_EOF
  1817. if test 1034 -ne "`wc -c < 'getopt.c'`"
  1818. then
  1819.     echo shar: "error transmitting 'getopt.c'" '(should have been 1034 characters)'
  1820. fi
  1821. fi
  1822. echo shar: "extracting 'help.c'" '(1786 characters)'
  1823. if test -f 'help.c'
  1824. then
  1825.     echo shar: "will not over-write existing file 'help.c'"
  1826. else
  1827. sed 's/^X//' << \SHAR_EOF > 'help.c'
  1828. X/*
  1829. X * Display the help screen.  Press any key to continue.  If the ascii_hot
  1830. X * string is more than 4 characters wide, this screen will look silly.
  1831. X * Maybe one day, this will also contain page-full descriptions of each
  1832. X * command.
  1833. X */
  1834. X
  1835. X#include <stdio.h>
  1836. X#include <curses.h>
  1837. X#include "misc.h"
  1838. X
  1839. Xvoid
  1840. Xhelp_screen(hot, fd)
  1841. Xchar *hot;
  1842. Xint fd;
  1843. X{
  1844. X    WINDOW *h_win, *newwin();
  1845. X
  1846. X    h_win = newwin(17, 80, 0, 0);
  1847. X
  1848. X    mvwattrstr(h_win, 1, 29, A_BOLD, "P C O M M       H E L P\n");
  1849. X    waddstr(h_win, "-------------------------------------------------------------------------------\n\n");
  1850. X    wattrstr(h_win, A_BOLD, "        Major Functions         Utility Functions         File Functions\n\n");
  1851. X    wprintw(h_win, "  Dialing Directory .%4.4s-D  Program Info .....%4.4s-I  Send files ....%4.4s-up\n", hot, hot, hot);
  1852. X    wprintw(h_win, "  Auto Redial .......%4.4s-R  Setup Screen .....%4.4s-S  Receive files .%4.4s-dn\n", hot, hot, hot);
  1853. X    wprintw(h_win, "  Keyboard Macros ...%4.4s-M  Change Directory .%4.4s-B  Directory .....%4.4s-F\n", hot, hot, hot);
  1854. X    wprintw(h_win, "  Line Settings .....%4.4s-P  Clear Screen .....%4.4s-C  Screen Dump ...%4.4s-G\n", hot, hot, hot);
  1855. X    wprintw(h_win, "  Exit Pcomm ........%4.4s-X  Toggle Duplex ....%4.4s-E  Data Logging ..%4.4s-1\n", hot, hot, hot);
  1856. X    wprintw(h_win, "  Unix Gateway ......%4.4s-4  Hangup Phone .....%4.4s-H  Toggle Log ....%4.4s-2\n", hot, hot, hot);
  1857. X    mvwprintw(h_win, 12, 29, "Printer On/Off ...%4.4s-L", hot);
  1858. X    mvwprintw(h_win, 13, 29, "Toggle CR/CR-LF ..%4.4s-3", hot);
  1859. X    mvwprintw(h_win, 14, 29, "Break Key ........%4.4s-7", hot);
  1860. X
  1861. X    box(h_win, '|', '-');
  1862. X    mvwaddstr(h_win, 16, 27, " Press any key to continue ");
  1863. X    wmove(h_win, 16, 79);
  1864. X    wrefresh(h_win);
  1865. X
  1866. X    wgetch(h_win);
  1867. X    if (fd == -1) {
  1868. X        werase(h_win);
  1869. X        wrefresh(h_win);
  1870. X    }
  1871. X    delwin(h_win);
  1872. X    return;
  1873. X}
  1874. SHAR_EOF
  1875. if test 1786 -ne "`wc -c < 'help.c'`"
  1876. then
  1877.     echo shar: "error transmitting 'help.c'" '(should have been 1786 characters)'
  1878. fi
  1879. fi
  1880. echo shar: "extracting 'info.c'" '(1269 characters)'
  1881. if test -f 'info.c'
  1882. then
  1883.     echo shar: "will not over-write existing file 'info.c'"
  1884. else
  1885. sed 's/^X//' << \SHAR_EOF > 'info.c'
  1886. X/*
  1887. X * Display the initial welcome screen (to include all of the proper
  1888. X * acknowledgements).  Press any key to continue.
  1889. X */
  1890. X
  1891. X#include <stdio.h>
  1892. X#include <curses.h>
  1893. X
  1894. Xinfo(fd)
  1895. Xint fd;
  1896. X{
  1897. X    WINDOW *w_win, *newwin();
  1898. X                    /* display the welcome screen */
  1899. X    w_win = newwin(23, 80, 0, 0);
  1900. X
  1901. X    mvwaddstr(w_win, 2, 18, "PPPPPP    CCCC    OOOO    MM   MM   MM   MM");
  1902. X    mvwaddstr(w_win, 3, 18, "P    P   C       O    O   M M M M   M M M M");
  1903. X    mvwaddstr(w_win, 4, 18, "PPPPPP   C       O    O   M  M  M   M  M  M");
  1904. X    mvwaddstr(w_win, 5, 18, "P        C       O    O   M     M   M     M");
  1905. X    mvwaddstr(w_win, 6, 18, "P         CCCC    OOOO    M     M   M     M");
  1906. X
  1907. X    mvwaddstr(w_win, 10, 5, "Pcomm is a public domain telecommunication program for Unix designed");
  1908. X    mvwaddstr(w_win, 11, 5, "to operate similar to the popular MSDOS program, ProComm.  ProComm (TM)");
  1909. X    mvwaddstr(w_win, 12, 5, "is copyrighted by Datastorm Technologies, Inc.  This is a completely");
  1910. X    mvwaddstr(w_win, 13, 5, "new program and contains no ProComm source code.");
  1911. X    mvwaddstr(w_win, 19, 45, "Emmet P Gray");
  1912. X    mvwaddstr(w_win, 20, 45, "...ihnp4!uiucuxc!fthood!egray");
  1913. X
  1914. X    wmove(w_win, 22, 79);
  1915. X    wrefresh(w_win);
  1916. X    
  1917. X    wgetch(w_win);
  1918. X    if (fd == -1) {
  1919. X        werase(w_win);
  1920. X        wrefresh(w_win);
  1921. X    }
  1922. X    delwin(w_win);
  1923. X    return;
  1924. X}
  1925. SHAR_EOF
  1926. if test 1269 -ne "`wc -c < 'info.c'`"
  1927. then
  1928.     echo shar: "error transmitting 'info.c'" '(should have been 1269 characters)'
  1929. fi
  1930. fi
  1931. echo shar: "extracting 'init.c'" '(3537 characters)'
  1932. if test -f 'init.c'
  1933. then
  1934.     echo shar: "will not over-write existing file 'init.c'"
  1935. else
  1936. sed 's/^X//' << \SHAR_EOF > 'init.c'
  1937. X/*
  1938. X * Display the welcome screen and find the pcomm files.  Returns a
  1939. X * pointer to the STATUS structure.  All errors are fatal.
  1940. X */
  1941. X
  1942. X#define DEFAULT "/usr/local/lib/pcomm"
  1943. X#define VERSION "1.0"
  1944. X
  1945. X#include <stdio.h>
  1946. X#include <curses.h>
  1947. X#include "misc.h"
  1948. X#include "status.h"
  1949. X
  1950. Xstruct STATUS *
  1951. Xinit(extra, file)
  1952. Xchar *extra, *file;
  1953. X{
  1954. X    char *ans, *findfile(), *strdup(), *mktemp();
  1955. X    static struct STATUS s;
  1956. X    void s_error_win(), free_ptr();
  1957. X    extern char *null_ptr;
  1958. X                    /* find the support files */
  1959. X    if ((ans = findfile(extra, "pcomm.param")) == NULL)
  1960. X        s_error_win("Can't find pcomm.param file");
  1961. X    s.p_path = strdup(ans);
  1962. X
  1963. X    if ((ans = findfile(extra, "pcomm.dial_dir")) == NULL)
  1964. X        s_error_win("Can't find pcomm.dial_dir file");
  1965. X    s.d_path = strdup(ans);
  1966. X
  1967. X    if ((ans = findfile(extra, "pcomm.modem")) == NULL)
  1968. X        s_error_win("Can't find pcomm.modem file");
  1969. X    s.m_path = strdup(ans);
  1970. X                    /* some defaults */
  1971. X    s.lock_path = null_ptr;
  1972. X    s.vs_path = mktemp("/tmp/pcommXXXXXX");
  1973. X    s.log_path = strdup("NOT_DEFINED");
  1974. X    s.fd = -1;
  1975. X    s.log = 0;
  1976. X    s.print = 0;
  1977. X    s.msg = 0;
  1978. X    s.pid = -1;
  1979. X                    /* display herald if no short-cut */
  1980. X    if (file == NULL) {
  1981. X
  1982. X        mvaddstr(2, 18, "PPPPPP    CCCC    OOOO    MM   MM   MM   MM");
  1983. X        mvaddstr(3, 18, "P    P   C       O    O   M M M M   M M M M");
  1984. X        mvaddstr(4, 18, "PPPPPP   C       O    O   M  M  M   M  M  M");
  1985. X        mvaddstr(5, 18, "P        C       O    O   M     M   M     M");
  1986. X        mvaddstr(6, 18, "P         CCCC    OOOO    M     M   M     M");
  1987. X
  1988. X        mvprintw(10, 26, ">>> Pcomm Version %s <<<", VERSION);
  1989. X        mvaddstr(13, 14, "A public domain telecommunication program for Unix");
  1990. X        mvaddstr(14, 8, "designed to operate similar to the popular MSDOS program, ProComm.");
  1991. X        mvaddstr(15, 11, "ProComm (TM) is copyrighted by Datastorm Technologies, Inc.");
  1992. X        mvaddstr(19, 45, "Emmet P. Gray");
  1993. X        mvaddstr(20, 45, "...!ihnp4!uiucuxc!fthood!egray");
  1994. X        move(LINES-1, COLS-1);
  1995. X        refresh();
  1996. X                    /* Delay so you can read the herald */
  1997. X        wait_key(stdscr, 5);
  1998. X    }
  1999. X    erase();
  2000. X    refresh();
  2001. X    free_ptr(extra);
  2002. X    return(&s);
  2003. X}
  2004. X
  2005. X/*
  2006. X * Search the extra directory (supplied on the command line), then the
  2007. X * directory in the PCOMM environmental variable, then the current directory,
  2008. X * and lastly, the default directory.
  2009. X */
  2010. X
  2011. Xchar *
  2012. Xfindfile(extra, name)
  2013. Xchar *extra, *name;
  2014. X{
  2015. X    int i;
  2016. X    static char temp[200];
  2017. X    char *pcomm, *getenv(), *path, pbuf[200], *getcwd();
  2018. X    
  2019. X                    /* see if PCOMM variable is set */    
  2020. X    pcomm = getenv("PCOMM");
  2021. X    if (pcomm == NULL || *pcomm == NULL)
  2022. X        pcomm = NULL;
  2023. X    else {
  2024. X                    /* zap the trailing separator */
  2025. X        if (pcomm[strlen(pcomm)-1] == '/')
  2026. X            pcomm[strlen(pcomm)-1] = NULL;
  2027. X    }
  2028. X
  2029. X    for (i=0; i<4; i++) {
  2030. X                    /* directory search order */
  2031. X        switch(i) {
  2032. X            case 0:
  2033. X                path = extra;
  2034. X                break;
  2035. X            case 1:
  2036. X                path = pcomm;
  2037. X                break;
  2038. X            case 2:
  2039. X                path = getcwd(pbuf, 200);
  2040. X                break;
  2041. X            case 3:
  2042. X                path = DEFAULT;
  2043. X                break;
  2044. X        }
  2045. X        sprintf(temp, "%s/%s", path, name);
  2046. X                    /* read permission checked */
  2047. X        if (!access(temp, 4))
  2048. X            return(temp);
  2049. X    }
  2050. X    return(NULL);
  2051. X}
  2052. X
  2053. X/*
  2054. X * Handle fatal errors, similar to error_win() but we can't rely on
  2055. X * the status structure (since it hasn't been created yet!).
  2056. X */
  2057. X
  2058. Xvoid
  2059. Xs_error_win(str)
  2060. Xchar *str;
  2061. X{
  2062. X    WINDOW *se_win, *newwin();
  2063. X    void exit();
  2064. X
  2065. X    se_win = newwin(7, 70, 9, 5);
  2066. X                    /* display the nasty note */
  2067. X    mvwaddstr(se_win, 2, 4, str);
  2068. X    mvwattrstr(se_win, 5, 24, A_BLINK, "Press any key to exit");
  2069. X    box(se_win, '|', '-');
  2070. X    beep();
  2071. X    wrefresh(se_win);
  2072. X
  2073. X    wgetch(se_win);
  2074. X    delwin(se_win);
  2075. X                    /* erase the window we made */
  2076. X    touchwin(stdscr);
  2077. X    erase();
  2078. X    refresh();
  2079. X    endwin();
  2080. X    exit(1);
  2081. X}
  2082. SHAR_EOF
  2083. if test 3537 -ne "`wc -c < 'init.c'`"
  2084. then
  2085.     echo shar: "error transmitting 'init.c'" '(should have been 3537 characters)'
  2086. fi
  2087. fi
  2088. exit 0
  2089. #    End of shell archive
  2090.  
  2091.  
  2092.